﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Engine.Graphics
{
    public class DrawableEntity : Entity, IDrawable
    {
        protected int drawOrder;
        protected bool visible;

        #region Constructors

        public DrawableEntity(Entity parent)
            : base(parent)
        {
            visible = true;
        }

        public override void Update(GameTime gameTime)
        {
            OnDrawOrderChanged();
            OnVisibleChanged();

            base.Update(gameTime);
        }

        protected void OnDrawOrderChanged()
        {
            if (DrawOrderChanged != null)
                DrawOrderChanged(this, null);
        }

        protected void OnVisibleChanged()
        {
            if (VisibleChanged != null)
                VisibleChanged(this, null);
        }
        #endregion

        #region IDrawable Members

        public virtual void Draw(GameTime gameTime)
        {
            //Draw logic here.
        }

        public int DrawOrder
        {
            get { return drawOrder; }
            set { drawOrder = value; }
        }

        public event EventHandler<EventArgs> DrawOrderChanged;

        public bool Visible
        {
            get { return visible; }
            set { visible = value; }
        }

        public event EventHandler<EventArgs> VisibleChanged;

        #endregion
    }
}
